package com.huike.business.service.impl;


import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.domain.vo.BusinessTrackVo;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.DictUtils;
import com.huike.common.utils.SecurityUtils;
import org.apache.poi.ss.formula.functions.T;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * 商机跟进记录Service业务层处理
 * 
 * @author wgl
 * @date 2021-04-28
 */
@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

   @Autowired
    private TbBusinessTrackRecordMapper trackRecordMapper;

    @Override
    public int addBusinessTrackRecord(BusinessTrackVo businessTrackVo) {

        String time = DateUtils.getTime();
        String username = SecurityUtils.getUsername();
        return  trackRecordMapper.addBusinessTrackRecord(businessTrackVo,time,username);
    }

    @Override
    public List<TbBusinessTrackRecord> selectList(Long id) {

        List<TbBusinessTrackRecord> trackRecords = trackRecordMapper.selectList(id);

        for (TbBusinessTrackRecord trackRecord : trackRecords) {
            String keyItems = trackRecord.getKeyItems();
            List<String> keys = new ArrayList<>();
            String[] split = keyItems.split(",");
            for (String s : split) {
                String label = DictUtils.getDictLabel("communication_point", s);
                keys.add(label);
            }
            trackRecord.setKeys(keys);
        }
        return trackRecords;
    }


}
